package com.wp;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Class cla = Class.forName("com.wp.Person");
        Object obj = cla.newInstance(); // 调用Person类的无参构造创建Person类的实例
        System.out.println(obj);

        Constructor c1 = cla.getDeclaredConstructor(); // 获取Person的无参构造public Person()
        Object object = c1.newInstance();
        System.out.println(object);

    }

}
